package com.zyh.thread.demo4;

import java.io.Serial;
import java.io.Serializable;

/**
 * @Author zyh
 * @Date 2024/8/8 14:44
 * @Description 商品类
 */

public class Product implements Serializable {
    @Serial
    private static final long serialVersionUID = -8582692471086552037L;
    private String name;
    private String color;

    public Product() {
    }

    public Product(String name, String color) {
        this.name = name;
        this.color = color;
    }

    public String getName() {
        return name;
    }

    public void setName(String name) {
        this.name = name;
    }

    public String getColor() {
        return color;
    }

    public void setColor(String color) {
        this.color = color;
    }

    @Override
    public String toString() {
        return "Product{" +
                "name='" + name + '\'' +
                ", color='" + color + '\'' +
                '}';
    }

    @Override
    public boolean equals(Object o) {
        if (this == o) return true;
        if (o == null || getClass() != o.getClass()) return false;

        Product product = (Product) o;

        if (name != null ? !name.equals(product.name) : product.name != null) return false;
        return color != null ? color.equals(product.color) : product.color == null;
    }

    @Override
    public int hashCode() {
        int result = name != null ? name.hashCode() : 0;
        result = 31 * result + (color != null ? color.hashCode() : 0);
        return result;
    }
}
